import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// element-plus
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import postcssPxtorem from 'postcss-pxtorem' // 直接导入模块
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      resolvers: [ElementPlusResolver()]
    })
  ],
  data: '',
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css: {
    postcss: {
      plugins: [
        postcssPxtorem({
          // 直接使用函数
          rootValue: 170.7, // 设计稿宽度 / 10
          propList: ['*'],
          selectorBlackList: [],
          minPixelValue: 2,
          exclude: /node_modules/i
        })
      ]
    }
  },
  server: {
    host: '0.0.0.0', // 设置host为'0.0.0.0'以允许在任何网络接口上访问
    port: 5173 // 可选，‌设置服务器端口号
    // 其他server配置项...
  }
})
